package org.opens.javaskill.jvm.classloader.encryption;

import org.junit.Test;

/**
 * @Date 2020/10/30 20:44
 * @Created by 99126
 */
public class SimpleEncrypt {

    private static final String plain = "hello world";

    private static final byte ENCRYPT_FACTOR = (byte) 0x0f;

    /**
     * 功能:
     * <p></p>
     * 输出:
     * <pre>
     *
     * </pre>
     * 说明:
     * <pre>
     *      1.
     * </pre>
     */
    @Test
    public void test24() {
        // 加密过程
        byte[] bytes = plain.getBytes();
        byte[] encrypt = new byte[bytes.length];
        for (int i = 0; i < bytes.length; i++) {
            encrypt[i] = (byte) (bytes[i] ^ ENCRYPT_FACTOR);
        }
        String result1 = new String(encrypt);
        System.out.println(result1);

        // 解密过程
        byte[] bytes1 = result1.getBytes();
        byte[] encrypt1 = new byte[bytes1.length];
        for (int i = 0; i < bytes1.length; i++) {
            encrypt1[i] = (byte) (bytes1[i] ^ ENCRYPT_FACTOR);
        }
        String result2 = new String(encrypt1);
        System.out.println(result2);
    }

    /**
     * 功能:
     * <p></p>
     * 输出:
     * <pre>
     *
     * </pre>
     * 说明:
     * <pre>
     *      1.
     * </pre>
     */
    @Test
    public void test51() {
        int x = 0xff;
        final byte y = (byte) 0xff;

        System.out.println(Byte.MAX_VALUE);
        System.out.println(y);
    }

}
